from django.db import models

# Create your models here.
class clientranking(models.Model):
    """
    用户客户端数据表
    """
    name = models.CharField(max_length=50, verbose_name='客户端名称')
    fraction = models.IntegerField(verbose_name='分数', default=0)
    created = models.DateTimeField(auto_now=True, verbose_name='最后操作时间')
    def __str__(self):
        return str(self.name)

    class Meta:
        ordering = ('-fraction',)
        verbose_name = '用户客户端'
        verbose_name_plural = '用户客户端'

class historyfraction(models.Model):
    """
    客户端历史分数数据表
    """
    operate = models.ForeignKey(to=clientranking, verbose_name='客户端', on_delete=models.CASCADE, null=True,
                                blank=True)
    hfraction = models.IntegerField(verbose_name='分数', default=0)
    created = models.DateTimeField(auto_now_add=True, verbose_name='操作时间')

    def __str__(self):
        return str(self.operate)

    class Meta:
        ordering = ('-pk',)
        verbose_name = '客户端历史分数'
        verbose_name_plural = '客户端历史分数'